package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;

class zaky extends CollectionBase implements zahd {
   private zif b;

   zaky(zif var1) {
      this.b = var1;
   }

   public zala b(int var1) {
      return (zala)this.a.get(var1);
   }

   public zahe a(int var1) {
      zala var2 = new zala(this.b, this.b.x(), var1);
      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var2);
      return var2;
   }

   public int a(zala var1) {
      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var1);
      return this.a.size() - 1;
   }

   int a() {
      int var1 = 0;
      Iterator var2 = this.a.iterator();

      while(var2.hasNext()) {
         zala var3 = (zala)var2.next();
         if (!var3.b()) {
            ++var1;
         }
      }

      return var1;
   }

   ArrayList a(boolean var1, boolean var2) {
      ArrayList var3 = this.a(1, false);
      ArrayList var4 = this.a(1, true);
      ArrayList var5 = this.a(2, false);
      ArrayList var6 = this.a(2, true);
      boolean var7 = this.b.e().p();
      boolean var8 = this.b.E().p();
      boolean var9 = true;
      ArrayList var10 = this.b.z().j();
      if (var10.size() > 0 && ((zbcp)var10.get(0)).j()) {
         var9 = false;
      }

      boolean var11 = false;
      zbcp var12;
      if (var3.size() > 0) {
         var12 = ((zala)var3.get(0)).i();
         if (var12.an() || var12.ap()) {
            var11 = true;
         }
      }

      if (var4.size() > 0) {
         var12 = ((zala)var4.get(0)).i();
         if (var12.an() || var12.ap()) {
            var11 = true;
         }
      }

      if (var2) {
         if (!var11) {
            if (!var7 && var1) {
               var3 = this.a(var3);
               var4 = this.a(var4);
               Collections.reverse(var5);
               Collections.reverse(var6);
            }
         } else if (var8 && var1) {
            var3 = this.a(var3);
            var4 = this.a(var4);
            Collections.reverse(var5);
            Collections.reverse(var6);
         }
      } else if (var11 && var1) {
         var3 = this.a(var3);
         var4 = this.a(var4);
         Collections.reverse(var5);
         Collections.reverse(var6);
      }

      ArrayList var13 = new ArrayList();
      if (var9) {
         com.aspose.cells.b.a.a.ze.a(var13, (Collection)var3);
         com.aspose.cells.b.a.a.ze.a(var13, (Collection)var4);
         com.aspose.cells.b.a.a.ze.a(var13, (Collection)var5);
         com.aspose.cells.b.a.a.ze.a(var13, (Collection)var6);
      } else {
         com.aspose.cells.b.a.a.ze.a(var13, (Collection)var4);
         com.aspose.cells.b.a.a.ze.a(var13, (Collection)var3);
         com.aspose.cells.b.a.a.ze.a(var13, (Collection)var6);
         com.aspose.cells.b.a.a.ze.a(var13, (Collection)var5);
      }

      return var13;
   }

   zala c(int var1) {
      Iterator var2 = this.a.iterator();

      zala var3;
      do {
         if (!var2.hasNext()) {
            return null;
         }

         var3 = (zala)var2.next();
      } while(var3.f() != var1);

      return var3;
   }

   private ArrayList a(ArrayList var1) {
      ArrayList var2 = new ArrayList();
      zbcp var3 = null;
      if (var1.size() <= 0) {
         return var1;
      } else {
         var3 = ((zala)var1.get(0)).i();
         ArrayList var4 = new ArrayList();
         com.aspose.cells.b.a.a.ze.a(var4, var1.get(0));
         com.aspose.cells.b.a.a.ze.a(var2, (Object)var4);

         ArrayList var6;
         for(int var7 = 1; var7 < var1.size(); ++var7) {
            zala var5 = (zala)var1.get(var7);
            if (var5.i().ag() == var3.ag()) {
               var6 = (ArrayList)var2.get(var2.size() - 1);
               com.aspose.cells.b.a.a.ze.a(var6, var1.get(var7));
            } else {
               var3 = var5.i();
               var6 = new ArrayList();
               com.aspose.cells.b.a.a.ze.a(var6, var1.get(var7));
               com.aspose.cells.b.a.a.ze.a(var2, (Object)var6);
            }
         }

         var4 = new ArrayList();

         for(int var8 = 0; var8 < var2.size(); ++var8) {
            var6 = (ArrayList)var2.get(var8);
            Collections.reverse(var6);
            com.aspose.cells.b.a.a.ze.a(var4, (Collection)var6);
         }

         return var4;
      }
   }

   private ArrayList a(int var1, boolean var2) {
      ArrayList var3 = new ArrayList();

      for(int var4 = 0; var4 < this.getCount(); ++var4) {
         zala var5 = this.b(var4);
         if (var5.h() == var1 && var5.i().j() == var2) {
            com.aspose.cells.b.a.a.ze.a(var3, (Object)var5);
         }
      }

      return var3;
   }

   public void a(int var1, zala var2) {
      this.a.add(var1, var2);
   }

   boolean b() {
      if (this.a == null) {
         return false;
      } else {
         Iterator var1 = this.a.iterator();

         zala var2;
         do {
            if (!var1.hasNext()) {
               return false;
            }

            var2 = (zala)var1.next();
            if (var2.h() == 2) {
               return true;
            }
         } while(var2.h() != 1 || !var2.i().ak());

         return true;
      }
   }

   // $FF: synthetic method
   public Object get(int x0) {
      return this.b(x0);
   }
}
